﻿using Painter.Component;
using Socks.Component.License;
using Socks.Platform.SDK;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Painter
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                base.OnStartup(e);
                //for test
                new MainWindow().Show();
                return;

                //本地软件序列号获取--只是示例 实际可加密
                string license = XmlManage.GetConfigurationValue("License");

                //初始化平台SDK
                SocksAPI socks = SocksAPI.GetSDK("socks226d927dd9cf7c13", "7189055795204b535dbe1657578edda5");
                LicenseCheckHelper.CheckLicense(license, 90, new RegisterDelegate((a, b, s) =>{
                //序列号验证通过后 会进入该回调
                    if (b){
                        //本地软件序列号设置--只是示例 实际可加密
                        XmlManage.SetConfiguration("License", s);
                        MainWindow window = new MainWindow();
                        window.Show();
                    }
                }));
            }
            catch (Exception ex) {
                File.WriteAllText("error.log", ex.Message);
                Application.Current.Shutdown();
            }
        }
    }
}
